from gmpy2 import *
from functools import reduce

def CRT(mi, ai):
    assert(reduce(gcd,mi)==1)
    assert (isinstance(mi, list) and isinstance(ai, list))
    M = reduce(lambda x, y: x * y, mi)
    ai_ti_Mi = [a * (M // m) * invert(M // m, m) for (m, a) in zip(mi, ai)]
    return reduce(lambda x, y: x + y, ai_ti_Mi) % M


e = 65537
n = 20446305236294581881140725938833605520023786992590821920806811572505477606387830733060901955371457846738863889279107367753914707053108524516947943610226964107558978693717655472431318403586269727573489946433389159145602800207787382180423611018458189828931572992863289292613405218278949739073786959411566919119158325510346523951336418479951932209799501108477995314359188860274532542630968951457343647522078553891223764285682602714616115281040492374167771746275218863543545907073818468841626731849010162645256595641473022327747346052186526727216525426337190917106751151745388854749923598231196090790074682287345100965373
dp = 158325084409606165134868956023907667507671677832027168046364315703295407017343206432691817272550256085313093440797443736742051552429653661451417133052016647805226890534559578502154540190596419643135611407218228612201386225040438407799879719366484669372051153511312310009858718254183049095347658106745575535469
leak_c1 = 116908580792713727509554342060190793142033425411766631165842865699167747112494944492849392371565838125428644563687571660329763478509815200537676368326781342382868082294015200439334832938068779547847851748337854603115134732593759473453640093195977206450633212921689957303431235603192670553553803757864481012599
leak_c2 = 18319344794671185787719339480953236221170603508712466350928025351527616335735433941953520711516118072282425397883638101260674452825151245435529613074796106769481242318321469286177813223159476396555044378245229663195991557031227024085316255781963813911437991309663376270820486723382786632243229800891705679245
for i in range(1, e):
    p = (dp*e-1)//i+1
    if n%p == 0:
        q = n//p
        break
print(p, q)
d = invert(e, (p-1)*(q-1))
c = CRT([p, q], [leak_c1, leak_c2])
m = pow(c, d, n)
flag = bytes.fromhex(hex(m)[2:]).decode()
print(flag) # bugku{d583310f-2add-4559-957e-8f6193eeb8f7}